<html>
	<title>eBuildy Error!</title>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<style>
			.message {margin:1em 0px;padding:1em;background-color:#FFF1A8;-moz-border-radius: 5px;-webkit-border-radius: 5px;}
			.trace {margin-bottom:10px;padding:1em;background:#F0F0F0;border:1px solid #C0C0C0;}
			
			* {margin:0; padding:0; font-family:Arial,sans-serif;}
			
			BODY {margin:2em;}
			
			.title {font-size:15px;display:block;padding:5px;background-color:#EBEFF9;}

			#nested {list-style:none; color:#033;font-size:11px;}
			#nested h3 {font-size:13px;border-bottom:1px solid #EBEFF9;padding:6px 6px 8px; font-weight:bold; margin-top:5px; cursor:pointer;}
			#nested h3.selected,#nested h3:hover {text-decoration:underline;background-color:#EBEFF9;}
			#nested .acc-section {overflow:hidden; background:#fff}
			#nested .acc-content {padding:15px; border:1px solid #C9D7F1; border-top:none; background:#fff}
			
			#code {list-style:none;}
			#code li {height:20px;display:block;line-height:20px;}
		</style>
	</head>
	<body bgcolor="#FFFFFF">
	<?php
		echo "<h3 class='title'>eBuildy: error!</h3><br />";
		
		echo "In the file ".$e->getFile()." at line ".$e->getLine().":";
		echo "<div class='message'>".$e->getMessage()."</div>";				
			
		echo "<h3 class='title'>Stack Trace:</h3>";
		
		echo '<ul class="acc" id="nested">';
		
		echo "<li><h3>".$e->getFile()." line ".$e->getLine()."</h3>";
		echo "<div class='acc-section'><div class='acc-content'>";
		
		readFile_($e->getFile(),$e->getLine());
		
		echo "</div></div></li>";		
		
		foreach ($e->getTrace() AS $item)
		{
			if (isset($item['file']) && isset($item['line']))
			{
				echo "<li><h3>".$item['file']." line <b>".$item['line']."</b></h3>";
				
				echo "<div class='acc-section'><div class='acc-content'>";
				
				echo "<blockquote>function <b>".$item['function']."</b> (";
				var_dump($item['args']);
				echo ")</blockquote><br /><br />";
				
				readFile_($item['file'],$item['line']);
				
				echo "</div></div>";
				
				echo "</li>";
			}
		}
		
		echo "</ul>";
		
		function readFile_($file_,$line_)
		{
			$handle = @fopen($file_, "r");
			
			if ($handle) 
			{
				$line = 0;
				
				echo "<ul id='code'>";
				
				while (!feof($handle)) 
				{
					$buffer = fgets($handle, 4096);
									
					if ($line > $line_ - 10 && $line < $line_ + 10)
					{
						$buffer = htmlentities($buffer);
					
						$i = 20 * substr_count($buffer,"\t") - 20;
					
						$c = $line%2 ? '#FFFFFF' : '#F0F0F0';
						
						if ($line + 1 == $line_) $c = "#FF7F7F";
						
						echo "<li style='background-color:$c;'>".($line+1).":Â <span style='padding-left:".$i."px;'>$buffer</span></li>";
					}
					
					$line ++;
				}
				
				echo "</ul>";
				
				fclose($handle);
			}		
		}
	?>		
	
	<script type="text/javascript">

		var TINY={};
		
		function T$(i){return document.getElementById(i)}
		function T$$(e,p){return p.getElementsByTagName(e)}

		TINY.accordion=function(){
			function slider(n){this.n=n; this.a=[]}
			slider.prototype.init=function(t,e,m,o,k){
				var a=T$(t), i=s=0, n=a.childNodes, l=n.length; this.s=k||0; this.m=m||0;
				for(i;i<l;i++){
					var v=n[i];
					if(v.nodeType!=3){
						this.a[s]={}; this.a[s].h=h=T$$(e,v)[0]; this.a[s].c=c=T$$('div',v)[0]; h.onclick=new Function(this.n+'.pr(0,'+s+')');
						if(o==s){h.className=this.s; c.style.height='auto'; c.d=1}else{c.style.height=0; c.d=-1} s++
					}
				}
				this.l=s
			};
			slider.prototype.pr=function(f,d){
				for(var i=0;i<this.l;i++){
					var h=this.a[i].h, c=this.a[i].c, k=c.style.height; k=k=='auto'?1:parseInt(k); clearInterval(c.t);
					if((k!=1&&c.d==-1)&&(f==1||i==d)){
						c.style.height=''; c.m=c.offsetHeight; c.style.height=k+'px'; c.d=1; h.className=this.s; su(c,1)
					}else if(k>0&&(f==-1||this.m||i==d)){
						c.d=-1; h.className=''; su(c,-1)
					}
				}
			};
			function su(c){c.t=setInterval(function(){sl(c)},20)};
			function sl(c){
				var h=c.offsetHeight, d=c.d==1?c.m-h:h; c.style.height=h+(Math.ceil(d/5)*c.d)+'px';
				c.style.opacity=h/c.m; c.style.filter='alpha(opacity='+h*100/c.m+')';
				if((c.d==1&&h>=c.m)||(c.d!=1&&h==1)){if(c.d==1){c.style.height='auto'} clearInterval(c.t)}
			};
			return{slider:slider}
		}();

		var nestedAccordion=new TINY.accordion.slider("nestedAccordion");
		nestedAccordion.init("nested","h3",1,-1,"selected");

	</script>

	
	</body>
</html>